/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package atm.charts;

import com.alee.laf.panel.WebPanel;
import java.awt.Color;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.xy.XYAreaRenderer2;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;

/**
 *
 * @author Quark
 */
public class AreaChartPanel extends WebPanel {
    
    final double[][] data = new double[][] {
            // [M, T, W, T, F, S, S]
            {1.0, 4.0, 3.0, 5.0, 5.0, 7.0, 1.0}, // 10s
            {5.0, 7.0, 6.0, 8.0, 4.0, 4.0, 5.0}, // 20s
            {4.0, 3.0, 2.0, 3.0, 6.0, 3.0, 2.0}, // 50s
            {8.0, 6.0, 0.0, 1.0, 3.0, 5.0, 7.0}  // 100s
        };
    
    public AreaChartPanel() {
        CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "D", data);
        
        ChartPanel chartPanel = new ChartPanel(createChart(dataset), false);
        chartPanel.setOpaque(false);
        
        this.add(chartPanel);    
    }
    
    private JFreeChart createChart(final CategoryDataset dataset) {
        // chart title, domain axis label, range axis label, data, orientation, include legend, tooltips, urls
        final JFreeChart chart = ChartFactory.createAreaChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, false, false);
        chart.setBackgroundPaint(null);
        
        final CategoryPlot plot = chart.getCategoryPlot();
        plot.setForegroundAlpha(0.7f);
        plot.setBackgroundPaint(null);
        plot.setOutlineVisible(false);
        plot.setDomainGridlinesVisible(false);
        plot.setRangeGridlinesVisible(false);
        
        final CategoryAxis domainAxis = plot.getDomainAxis();
        domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
        domainAxis.setLowerMargin(0.0);
        domainAxis.setUpperMargin(0.0);
        
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
        
        return chart;
    }    
}